package zzps.exeed.web.route;

import zzps.exeed.web.handle.Handler;
import zzps.exeed.web.http.HttpMethod;

public class Route {

    private String path;
    private HttpMethod[] method;
    private Handler handler;

    public Route(String path, HttpMethod[] method, Handler handler) {
        if (!path.startsWith("/")){
            path = "/" + path;
        }
        this.path = path;
        this.method = method;
        this.handler = handler;
    }

    public String getPath() {
        return path;
    }

    public HttpMethod[] getMethod() {
        return method;
    }

    public Handler getHandler() {
        return handler;
    }


    public boolean match(HttpMethod httpMethod){
        if (method.length == 0){
            return true;
        }
        for (HttpMethod m : method) {
            if (httpMethod == m){
                return true;
            }
        }
        return false;
    }
}
